{% extends 'backend/backend_base.html' %}

{% block content %}

    <table class="table table-striped">
        <thead>
        <tr>
            <th>标题</th>
            <th>评论数</th>
            <th>点赞数</th>
            <th>操作</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for article in article_list %}
            <tr>
                {#                                    <td><a href="/{{ article.blog.userinfo.username }}/article/{{ article.pk }}">{{ article.title }}</a></td>#}
                <td><a href="/{{ request.user.username }}/article/{{ article.pk }}">{{ article.title }}</a></td>
                <td>{{ article.commit_num }}</td>
                <td>{{ article.up_num }}</td>
                <td><a class="delete" style="cursor: pointer" id="{{ article.pk }}">删除</a></td>
                <td><a href="/edit/" name="">编辑</a></td>
            </tr>
        {% endfor %}
        </tbody>
    </table>

    <script>
        $(".delete").click(function () {
            var del = confirm("确定删除吗");
            var article_id = this.id;
            if (del == true) {
                $.ajax({
                    url: '/delete/',
                    type: 'post',
                    data: {
                        csrfmiddlewaretoken: '{{ csrf_token }}',
                        article_id: article_id,

                    },

                    success: function (data) {
                        console.log(data)
                        if (data.code == 100) {
                            location.href = '/backend/'
                            alert(data.msg)
                        }

                    }
                })
            }

        })

    </script>
{% endblock %}


